/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.GiaoVuDAO;
import TableModel.Giaovu;
import java.io.Serializable;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


/**
 *
 * @author vt
 */
public class GiaoVuDAOImpl extends HibernateDaoSupport implements GiaoVuDAO {

    @Override
    public Giaovu findGiaoVu(String id) {
       List list = this.getHibernateTemplate().find("from Giaovu giaovu where giaovu.magvu = ?", id);
		if(list.isEmpty()){
			return null;
		}
		return (Giaovu) list.get(0);

    }

    @Override
    public Giaovu findGiaoVu(String userName, String paawrod) {
       List list = this.getHibernateTemplate().find("from Giaovu giaovu where giaovu.name = ? and giaovu.password=?", userName,paawrod);
		if(list.isEmpty()){
			return null;
		}
		return (Giaovu) list.get(0);
    }

    @Override
    public List<Giaovu> findAllGiaoVu() {
       return this.getHibernateTemplate().find("from Giaovu giaovu  order by giaovu.name");
    }

    @Override
    public void addGiaoVu(Giaovu a) {
        Serializable save = getHibernateTemplate().save(a);
    }

    @Override
    public void deleteGiaovu(Giaovu a) {
         getHibernateTemplate().delete(a);
    }

    @Override
    public void editGiaovu(Giaovu a) {
        getHibernateTemplate().update(a);
    }
    
}
